package com.net.wanjian.networkhospitalmanager.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.net.wanjian.networkhospitalmanager.R;
import com.net.wanjian.networkhospitalmanager.adapter.base.RecyclerBaseAdapter;
import com.net.wanjian.networkhospitalmanager.bean.HomeItemBean;
import com.zhy.autolayout.utils.AutoUtils;

/**
 * Description:
 * Created by lidongcai on 2017/4/23.
 * Email:  lidongcaiocc@163.com
 */

public class HomeAdapter extends RecyclerBaseAdapter<HomeItemBean,HomeAdapter.ViewHolder> {

    public HomeAdapter(Context context) {
        super(context);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = inflater.inflate(R.layout.item_home, parent, false);
        AutoUtils.auto(view);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, HomeItemBean item, int position) {
//            holder.setmImageView(list.get(position).getRes());
//            holder.setmTextView(list.get(position).getText());
                holder.setmImageView(item.getRes());
                holder.setmTextView(item.getText());
    }

    public static class ViewHolder extends RecyclerView.ViewHolder{
        private ImageView mImageView;
        private TextView mTextView;
        public ViewHolder(View itemView) {
            super(itemView);

            mImageView = (ImageView) itemView.findViewById(R.id.item_home_iv);
            mTextView = (TextView) itemView.findViewById(R.id.item_home_tv);
        }

        public void setmImageView(int res){
            mImageView.setImageResource(res);
        }
        public void setmTextView(String text){
            mTextView.setText(text);
        }
    }
}
